<?php 
/***************************************************
 * FileUpload Component
 *
 * Manages uploaded files to be saved to the file system.
 *
 * @copyright    Copyright 2009, Webtechnick
 * @link         http://www.webtechnick.com
 * @author       Nick Baker
 * @version      1.4
 * @license      MIT
 */
class FileComponent extends Component{
  /* component configuration */
  var $name = 'SwfUploadComponent';
  var $params = array();
  var $errorCode = null;
  var $errorMessage = null;

  // file and path configuration
  var $uploadpath;
  var $webpath = '/files/';
  var $overwrite = false;
  var $filename;

  /**
   * Contructor function
   * @param Object &$controller pointer to calling controller
   */
  function startup(&$controller) {
    // initialize members
    $this->uploadpath = WWW_ROOT . DS . 'files' . DS;

    //keep tabs on mr. controller's params
    $this->params = $controller->params;
  }

  function upload() {
    $this->fileName = $this->params['form']['Filedata']['name'];
    $this->tmpFile = $this->params['form']['Filedata']['tmp_name'];
    $moved = move_uploaded_file($this->tmpFile, $this->uploadpath . $this->fileName);
  }

  function newFoldler() {

  }

}
?> 
